<template>
	<view>
		
	</view>
</template>

<script>
	import {getTenantIdByName,socialAuthRedirect} from '@/api/common.js'
	import { setToken, removeToken,setTenantId,getTenantId } from '@/utils/auth'
	export default {
		data() {
			return {
				redirect:'',
				option:{},
			};
		},
		methods:{
			// 社交登录
			async doSocialLogin(type){
			  try {
			    const res = await getTenantIdByName(this.option.name)
				console.log(res)
			    setTenantId(res.data)
			  } catch (error) {
			    if (error === 'cancel') return
			  } finally {
			  }
			  // 计算 redirectUri
			  // tricky: type、redirect需要先encode一次，否则钉钉回调会丢失。
			  // 配合 Login/SocialLogin.vue#getUrlValue() 使用
			  
			  const redirectUri =
			    location.origin +
			    '/#/pages/wxlogin?' +
			    encodeURIComponent(`type=${type}&redirect=${this.redirect || '/'}`)
				console.log(redirectUri)
			  // 进行跳转
			  let info = await socialAuthRedirect(type, encodeURIComponent(redirectUri))
			  window.location.href = info.data
			}
		},
		onLoad(option){
			console.log(option)
			this.option = option;
			this.doSocialLogin(35)
		},
		onShow() {
			
		}
	}
</script>

<style lang="less">

</style>
